<%--
  Created by IntelliJ IDEA.
  User: QLL
  Date: 2025/1/8
  Time: 上午1:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册用户</title>
    <script>
        window.onload = function() {
            var urlParams = new URLSearchParams(window.location.search);
            if (urlParams.has('error')) {
                alert("注册失败，请检查您的输入信息。");
            }
        };
        function validateForm() {
            var password = document.getElementById("password").value;
            var confirmPassword = document.getElementById("confirmPassword").value;
            if (password !== confirmPassword) {
                alert("两次输入的密码不一致！");
                return false; // 阻止表单提交
            }
            return true;
        }
    </script>
</head>
<body>
<h2>注册账号</h2>
<form action="RegisterServlet" method="post" onsubmit="return validateForm()">
    <div>
        <label>账号名:</label>
        <input type="text" name="username" required>
    </div>
    <div>
        <label for="sex">性别:</label>
        <select id="sex" name="sex" required>
            <option value="保密">保密</option>
            <option value="男">男</option>
            <option value="女">女</option>
        </select>
    </div>
    <div>
        <label for="peiceName">联系人:</label>
        <input type="text" id="peiceName" name="peiceName" required>
    </div>
    <div>
        <label for="phone">电话:</label>
        <input type="tel" id="phone" name="phone" required>
    </div>
    <div>
        <label for="province">省份:</label>
        <input type="text" id="province" name="province" required>
    </div>
    <div>
        <label for="district">地区:</label>
        <input type="text" id="district" name="district" required>
    </div>
    <div>
        <label for="detailAddress">详细地址:</label>
        <input type="text" id="detailAddress" name="detailAddress" required>
    </div>
    <div>
        <label>登录密码:</label>
        <input type="password" name="password" required>
    </div>
    <div>
        <label for="confirmPassword">确认密码:</label>
        <input type="password" id="confirmPassword" name="confirmPassword" required>
    </div>

    <div>
        <button type="submit">注册</button>
    </div>
</form>

<%-- 检查 URL 参数中是否存在 error 参数 --%>
<%--<c:if test="${param.error == 'true'}">
    <p style="color: red;">登录失败，请检查您的用户名和密码。</p>
</c:if>
--%>


</body>
</html>